// pages/yuncunchu/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },
  chooseImage(){
    let that=this
    wx.chooseImage({
      count: 1,
      sizeType: ['original', 'compressed'],
      sourceType: ['album', 'camera'],
      success (res) {
        // tempFilePath可以作为img标签的src属性显示图片
        const tempFilePaths = res.tempFilePaths[0]
        // console.log(res)
        that.uploadImage(tempFilePaths)
      }
    })

  },
  uploadImage(tempFilePaths){
    wx.cloud.uploadFile({
      cloudPath: 'example1.png',
      filePath: tempFilePaths, // 文件路径
    }).then(res => {
      // get resource ID
      console.log(res.fileID)
    }).catch(error => {
      // handle error
      console.log(error)
    })
  }

})